<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- 寄生组合式/原型式继承 -->
  <script src="./inherit_util.js"></script>
  <script>
     function Person(name, age) {
      this.name = name;
      this.age = age;
    }

    Person.prototype.running = function () {
      console.log('我在奔跑')
    }
    Person.prototype.eating = function () {
      console.log('我在吃饭')
    }
    function Stuedent(name, age, sno, score) {
      // 借用构造函数实现继承，缺点：1、构造函数被调用两次，2、stu1中存在两份父类的属性
      Person.call(this, name, age) //该this会指向new 创建的Student实例，也就是stu1
      this.sno = sno;
      this.score = score;
    }
    inherit(Stuedent,Person)
    var stu1 = new Stuedent()
    console.log(stu1);
  </script>
</body>
</html>